// Copyright (c) 2005  INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of cgal-python; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; version 2.1 of the License.
// See the file LICENSE.LGPL distributed with cgal-python.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $Id: Py_Triangle_2.cpp 167 2007-11-02 15:36:54Z spion $
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal-python/trunk/cgal-python/bindings/Kernel/Py_Triangle_2.cpp $
//
// Author(s)     : Naceur Meskini
//=========================================================================
//
#include <CGAL/basic.h>
#include <include/Kernels.h>

#include <boost/python.hpp>
#include <boost/cstdint.hpp>

const char* Triangle_2_doc[]={
"An object t of the class Triangle_2 is a triangle in the two-dimensional Euclidean plane.\n\
Triangle t is oriented, i.e., its boundary has clockwise or counterclockwise orientation. \n\
We call the side to the left of the boundary the positive side and the side to the right of the boundary the negative side.\n\
The boundary of a triangle splits the plane in two open regions, a bounded one and an unbounded one. \n\n\
For more details see a C++ doc:\n\
http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Kernel_23_ref/Class_Triangle_2.html",

"t.Triangle_2( Point_2 p,Point_2 q,Point_2 r) -> introduces a triangle t with vertices p, q and r.",

"t.area() -> double\nreturns the signed area of t.",

"t.orientation() -> Orientation\nreturns the orientation of t.",

"t.bounded_side( Point_2 p) -> Bounded_side\nreturns the constant ON_BOUNDARY, ON_BOUNDED_SIDE, or else ON_UNBOUNDED_SIDE,\ndepending on where point p is.\nPrecondition: t is not degenerate.",

"t.oriented_side( Point_2 p) -> Oriented_side\n\n\
returns ON_ORIENTED_BOUNDARY, or POSITIVE_SIDE, or the constant ON_NEGATIVE_SIDE,\n\
determined by the position of point p.\n\
Precondition: t is not degenerate.",

"t.vertex( int i) ->  Point_2\nreturns the i'th vertex modulo 3 of t.",

"t.has_on_bounded_side( Point_2 p) -> bool",

"t.has_on_unbounded_side( Point_2 p) -> bool",

"t.has_on_boundary( Point_2 p) -> bool",

"t.has_on_negative_side( Point_2 p) -> bool",

"t.has_on_positive_side( Point_2 p) -> bool",

"t.is_degenerate( Point_2 p) -> bool\ntriangle t is degenerate, if the vertices are collinear.",

"t.bbox( ) -> Bbox_2\nreturns a bounding box containing t.",

"t.opposite( ) -> Triangle_2\nreturns a triangle where the boundary is oriented the other way round\n(this flips the positive and the negative side, but not the bounded and unbounded side).",

"t.transform(  Aff_transformation_2 at) -> Triangle_2\nreturns the triangle obtained by applying at on the three vertices of t."
};

template<class Triangle_2>
boost::python::str py_repr_Triangle_2(const Triangle_2& t )
{
	using namespace boost::python;
	return str("Triangle_2("+ str(t.vertex(0)) +","+ str(t.vertex(1)) + "," + str(t.vertex(2)) + "," + str(t.orientation()) +")" );
}


template<class kernel>
void Py_Triangle_2()
{
	typedef typename kernel::Point_2 						Point_2;
	typedef typename kernel::Triangle_2 						Triangle_2;

	using namespace boost::python;

        class_< Triangle_2 >("Triangle_2", Triangle_2_doc[0], init<>())
        .def(init< const Triangle_2& >(Triangle_2_doc[1]))
        .def(init< const Point_2&, const Point_2&, const Point_2& >())
        .def("area", &Triangle_2::area, Triangle_2_doc[2])
        .def("orientation", &Triangle_2::orientation, Triangle_2_doc[3])
        .def("bounded_side", &Triangle_2::bounded_side, Triangle_2_doc[4])
        .def("oriented_side", &Triangle_2::oriented_side, Triangle_2_doc[5])
#if CGAL_VERSION_NR < 1030301000
        .def("vertex", &Triangle_2::vertex, by_cref(), Triangle_2_doc[6])
#else
        .def("vertex", &Triangle_2::vertex, typename Value_or_cref<typename kernel::Construct_vertex_2, Triangle_2, int > ::type(), Triangle_2_doc[6])
#endif
        .def("has_on_bounded_side", &Triangle_2::has_on_bounded_side, Triangle_2_doc[7])
        .def("has_on_unbounded_side", &Triangle_2::has_on_unbounded_side, Triangle_2_doc[8])
        .def("has_on_boundary", &Triangle_2::has_on_boundary, Triangle_2_doc[9])
        .def("has_on_negative_side", &Triangle_2::has_on_negative_side, Triangle_2_doc[10])
        .def("has_on_positive_side", &Triangle_2::has_on_positive_side, Triangle_2_doc[11])
        .def("is_degenerate", &Triangle_2::is_degenerate, Triangle_2_doc[12])
        .def("bbox", &Triangle_2::bbox, Triangle_2_doc[13])
        .def("opposite", &Triangle_2::opposite, Triangle_2_doc[14])
        .def("transform", &Triangle_2::transform, Triangle_2_doc[15])
	.def("__repr__", &py_repr_Triangle_2<Triangle_2>)

        .def( self == self )
        .def( self != self )
    ;
}


void export_Triangle_2()
{
	Py_Triangle_2<K>();
}
